package org.iks.user.enums;

import lombok.Getter;
import org.iks.common.enums.IEnum;
import org.springframework.lang.Nullable;

import java.util.Objects;

/**
 * Author kzou
 * Date 2024/5/23
 * Description: 好友关系状态
 */
@Getter
public enum ApplyFriendStatus implements IEnum<Integer> {

    /**
     * 正常状态
     */
    Normal(1),

    /**
     * 待同意
     */
    WaitForAgree(2),

    /**
     * 已经被删除了
     */
    Delete(3),

    /**
     * 已经被拉黑
     */
    BlackFriend(4),

    ;

    private final int code;

    ApplyFriendStatus(int code) {
        this.code = code;
    }

    @Nullable
    public static ApplyFriendStatus of(Integer code) {
        for (ApplyFriendStatus friendStatus : values()) {
            if (Objects.equals(friendStatus.getCode(), code)) {
                return friendStatus;
            }
        }
        return null;
    }

    @Override
    public Integer getUniqueCode() {
        return this.code;
    }

}
